package com.bigdata.bookinfo.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class KeyAndScore implements Writable {

    private String key;

    private double score;

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(key);
        dataOutput.writeDouble(score);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.key = dataInput.readUTF();
        this.score = dataInput.readDouble();
    }
}
